# reduceByKey是针对KV型的RDD，会自动安装Key分组，然后根据提供的聚合逻辑完整聚合操作
#coding:utf8
from pyspark import SparkContext,SparkConf

if __name__ == '__main__':
    conf = SparkConf().setAppName("test").setMaster("local[*]")
    sc = SparkContext(conf=conf)

    rdd = sc.parallelize([("a",1),("b",2),("c",3),("a",2),("b",3),("c",4)])
    print(rdd.reduceByKey(lambda x,y: x+y).collect())